home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / config / i386-emul / runprocess.s < prev    next >
Text File  |  1996-10-30  |  2KB  |  95 lines

  1. #    (C) 1995-96 AROS - The Amiga Replacement OS
  2. #    $Id: runprocess.s,v 1.7 1996/10/30 10:18:35 aros Exp $
  3. #
  4. #    Desc: DOS utility function RunProcess
  5. #    Lang: english
  6. #
  7. # LONG RunProcess ( struct Process         * proc,
  8. #            struct StackSwapStruct * sss,
  9. #            STRPTR             argptr,
  10. #            ULONG             argsize,
  11. #            LONG_FUNC             entry,
  12. #            struct DosLibrary       * DOSBase
  13.  
  14.     .include "machine.i"
  15.  
  16.     FirstArg = 4+(4*4)   /* Return-Adress + 4 Registers */
  17.     proc     = FirstArg
  18.     sss     = proc+4    /* 24 */
  19.     argptr     = sss+4
  20.     argsize  = argptr+4
  21.     entry     = argsize+4 /* 36 */
  22.     DOSBase  = entry+4
  23.  
  24.     .text
  25.     .balign 16
  26.     .globl    _Dos_RunProcess
  27.     .type    _Dos_RunProcess,@function
  28.  
  29. _Dos_RunProcess:
  30.     /* Save some registers */
  31.     pushl %edi
  32.     pushl %esi
  33.     pushl %ebx
  34.     pushl %ebp
  35.  
  36.     /* Fetch the arguments off the stack */
  37.     movl sss(%esp),%ebx
  38.     movl entry(%esp),%edi
  39.  
  40.     /* Move upper bounds of the new stack into eax */
  41.     movl stk_Upper(%ebx),%eax
  42.     /* Make room for one pointer */
  43.     addl $-4,%eax
  44.     /* Push sss onto the new stack */
  45.     movl %ebx,(%eax)
  46.  
  47.     /* Make room for another pointer */
  48.     addl $-4,%eax
  49.     /* Get SysBase */
  50.     movl DOSBase(%esp),%edx
  51.     movl dl_SysBase(%edx),%edx
  52.     /* Push SysBase on the new stack */
  53.     movl %edx,(%eax)
  54.  
  55.     /* Store switch point in sss */
  56.     movl %eax,stk_Pointer(%ebx)
  57.  
  58.     /* Push SysBase and sss on our stack */
  59.     pushl %edx /* SysBase */
  60.     pushl %ebx /* sss */
  61.     /* Switch stacks */
  62.     leal StackSwap(%edx),%edx
  63.     call *%edx
  64.     /* Clean (new) stack */
  65.     addl $8,%esp
  66.  
  67.     /* Call the specified routine */
  68.     call *%edi
  69.  
  70.     /* Store the result of the routine in esi */
  71.     movl %eax,%esi
  72.  
  73.     /* Swap the upper two values on the stack */
  74.     popl %edx /* SysBase */
  75.     popl %ebx /* sss */
  76.     pushl %edx /* SysBase */
  77.     pushl %ebx /* sss */
  78.     /* Switch stacks back */
  79.     leal StackSwap(%edx),%edx
  80.     call *%edx
  81.     /* Clean our stack */
  82.     addl $8,%esp
  83.  
  84.     /* Put the result in eax where our caller expects it */
  85.     movl %esi,%eax
  86.  
  87.     /* Restore registers */
  88.     popl %ebp
  89.     popl %ebx
  90.     popl %esi
  91.     popl %edi
  92.  
  93.     /* Done */
  94.     ret
  95.